// 递归生成树结构
export const generateTree = (treeData:any, parentId = 0) => {
  let tree:any = [];  
  treeData.forEach((item:any) => {  
    if (item.parentId === parentId) {  
      const children = generateTree(treeData, item.id);  
      if (children.length) {  
        item.children = children;  
      } else {  
        item.children = [];  
      }  
      tree.push(item);  
    }  
  });  
  return tree;
}